package com.zm.core.controller;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.jfinal.kit.PropKit;
import com.zm.core.common.controller.BaseController;
import com.zm.taobao.API;
import com.zm.taobao.Token;

public class TaobaoController extends BaseController {
	
	public void index() {
		HttpServletRequest req = getRequest();
		String gs= req.getParameter("code");
		Token.set(gs);
		redirect("/selleradmin/index");
	}

	public void grant()	{
		redirect(PropKit.use("shoesize.properties").get("taobao"));
	}
	public void logout(){
		HttpServletRequest req = getRequest();
		HttpServletResponse resp = getResponse();
		Cookie newCookie=new Cookie("JSESSIONID",null); //假如要删除名称为username的Cookie
		newCookie.setMaxAge(0); //立即删除型
		newCookie.setPath("/"); //项目所有目录均有效，这句很关键，否则不敢保证删除
		resp.addCookie(newCookie); //重新写入，将覆盖之前的
//		Cookie[] cookies=req.getCookies();
//		for (Cookie cookie : cookies) {
//			cookie.setMaxAge(0);
//			cookie.setPath("/");
//			resp.addCookie(cookie);
//		}
		render("");
		redirect(PropKit.use("shoesize.properties").get("logout"));
	}
}
